<template>
	<view>
		<view class="py10">
			<view @tap="selectArea(item)" class="px15 py10 dis-flex flex-align-center flex-between bg-fff bb" v-for="(item, index) in pageList" :key="index">
				<view class="lh26 fs16 c-333"><text>{{item.name}}</text></view>
				<u-icon class="flex-shrink ml5" name="arrow-right" size="30"></u-icon>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageList:[],
				submitInfo:{
					name:'',
				},
				level:1,
			}
		},
		onLoad(){
			this.loadArea();
		},
		methods: {
			loadArea(pId){
				this.$http.get(this.$config.UrlGetArea,{pid:pId||""}).then((res)=>{
					this.pageList = res.data || [];
					if(this.pageList.length == 0){
						if(this.submitInfo.name) this.submitInfo.name = this.submitInfo.name.substr(0,this.submitInfo.name.length - 1);
						this.$api.opener().areaConfirm(this.submitInfo);
						this.$api.back();
					}
				})
			},
			selectArea(item){
				switch (this.level){
					case 1:{
						this.submitInfo.province = item.id;
					}break;
					case 2:{
						this.submitInfo.city = item.id;
					}break;
					case 3:{
						this.submitInfo.district = item.id;
					}break;
					case 4:{
						this.submitInfo.town = item.id;
					}break;
					default: break;
				}
				this.submitInfo.name += item.name+'/';
				this.level ++;
				this.loadArea(item.id)
			}
		}
	}
</script>

<style>

</style>
